package com.yxj03;

import java.util.ArrayList;
import java.util.List;

public class forDemo {
    public static void main(String[] args) {
        int[] arr = {1,2,3,4,5};
        for(int i : arr) {
            System.out.println(i);
        }
        System.out.println("-----------");
        String[] strArray = {"hello","world","java"};
        for (String s: strArray) {
            System.out.println(s);
        }
        System.out.println("--------");
        //集合的遍历
        List<String> list = new ArrayList<String>();
        list.add("we");
        list.add("are");
        list.add("young");
        for(String s : list) {
            System.out.println(s);
        }
        System.out.println("----");
        //内部原理是一个Iterator迭代器--会引发并发修改异常
/*        for(String s:list) {
            if(s.equals("world")) {
                list.add("javaee");
            }
        }*/

    }
}
